import type { NextApiResponse } from 'next';
import * as newsDescService from '@/common/service/g_news_desc';
import R from '@common/type/response';
import { AuthenticatedRequest, withAuth } from '@common/middleware/auth';

export async function handler(req: AuthenticatedRequest, res: NextApiResponse) {
  if (req.method === 'GET') {
    const { alias } = req.query;
    if (!alias || typeof alias !== 'string') {
      res.status(400).json({ success: false, message: '缺少 alias 参数' });
      return;
    }
    const data = await newsDescService.getNewsDescByAlias(alias);
    R.success(res, data);
  } else {
    res.status(405).json({ success: false, message: 'Method Not Allowed' });
  }
}

export default withAuth(handler); 